/**
 * Created on Dec 10, 2006
 */
package info.niwota.js;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.OutputStream;

import org.inconspicuous.jsmin.JSMin;

/**
 * @author qiangli
 * 
 */
public class JSMinCompressor extends BaseCompressor implements Compressor {

	public JSMinCompressor() {
		super();
	}

	@Override
	public void compress(byte[] script, OutputStream out) throws Exception {
		InputStream in = new ByteArrayInputStream(script);
		try {
			JSMin jsmin = new JSMin(in, out);
			jsmin.jsmin();
			out.flush();
		} finally {
			close(in);
		}
	}
}
